package cn.tedu.csmall.product.webapi.service.impl;

import cn.tedu.csmall.pojo.entity.Goods;
import cn.tedu.csmall.pojo.entity.PmsSpu;
import cn.tedu.csmall.product.webapi.mapper.IGoodsMapper;
import cn.tedu.csmall.product.webapi.mapper.ISkuMapper;
import cn.tedu.csmall.product.webapi.mapper.ISpuDetailMapper;
import cn.tedu.csmall.product.webapi.mapper.ISpuMapper;
import cn.tedu.csmall.product.webapi.service.IGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Kiven
 */
@Service
public class GoodsServiceImpl implements IGoodsService {

    @Autowired
    private IGoodsMapper goodsMapper;

    @Autowired
    private ISpuMapper spuMapper;

    @Autowired
    private ISkuMapper skuMapper;

    @Autowired
    private ISpuDetailMapper spuDetailMapper;
    @Override
    public List<Goods> findGoods(PmsSpu spu) {

     return  goodsMapper.findGoods(spu);

        //List<Goods> goods = new ArrayList<>();
        //// 先查出spu
        //List<PmsSpu> spus = spuMapper.findSpus(spu);
        //// 再查出skulist
        //for (PmsSpu pmsSpu : spus) {
        //    List<PmsSku> skulist = skuMapper.findSkuBySpuId(pmsSpu.getId());
        //    // 再查出spuDetail
        //    PmsSpuDetail detail = spuDetailMapper.findDetailBySpuId(pmsSpu.getId());
        //
        //    Goods good = Goods.builder().pmsSpu(pmsSpu).skus(skulist).spuDetail(detail).build();
        //
        //    goods.add(good);
        //}
        //return goods;
    }
}
